<%--
  Created by IntelliJ IDEA.
  User: 25306
  Date: 2025/10/13
  Time: 上午9:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <title>评论审核</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/back-index.css"/>
    <script src="${pageContext.request.contextPath}/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap-paginator.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap-mypaginator.js"></script>

    <script type="text/javascript">
        $(function () {
            $("#nickname").val("${commentParam.nickname}");
            $("#context").val("${commentParam.context}");
            $("#createStartDate").val("${commentParam.createStartDate}");
            $("#createEndDate").val("${commentParam.createEndDate}");
            if("${commentParam.status}" != ""){
                $("#status").val("${commentParam.status}");
            }


            // 显示隐藏查询列表
            $('#show-user-search').click(function () {
                $('#show-user-search').hide();
                $('#upp-user-search').show();
                $('.showusersearch').slideDown(500);
            });
            $('#upp-user-search').click(function () {
                $('#show-user-search').show();
                $('#upp-user-search').hide();
                $('.showusersearch').slideUp(500);
            });

            //查询提交
            $("#doSearch").click(function () {
                $("#searchForm").submit();
            })
            //分页
            $("#userPageHelper").bootstrapPaginator({
                bootstrapMajorVersion: 3,
                currentPage: "${commentPage.pageNum == 0 ? 1 : commentPage.pageNum}",
                totalPages: "${commentPage.pages == 0 ? 1 : commentPage.pages}",
                size: "normal",
                alignment: "center",
                onPageClicked: function (event, originalEvent, type, page) {
                    $("#pageNo").val(page);
                    $("#searchForm").submit();
                }
            })
            $(".btn-sm0").click(function () {
                $.ajax({
                    type: "post",
                    url: "${pageContext.request.contextPath}/comment/enableById",
                    data: {"id": $(this).attr("data-id")},
                    dataType: "json",
                    success: function (result) {
                        if (result.responseCode == "2001") {
                            location.href = "${pageContext.request.contextPath}/comment/findAll?pageNo=${commentPage.pageNum == 0 ? 1 : commentPage.pageNum}";
                        } else {
                            $("#errorMsg").html(result.message);
                        }
                    }
                })
            })

            $(".btn-sm1").click(function () {
                $.ajax({
                    type: "post",
                    url: "${pageContext.request.contextPath}/comment/disableById",
                    data: {"id": $(this).attr("data-id")},
                    dataType: "json",
                    success: function (result) {
                        if (result.responseCode == "2001") {
                            location.href = "${pageContext.request.contextPath}/comment/findAll?pageNo=${commentPage.pageNum == 0 ? 1 : commentPage.pageNum}";
                        } else {
                            $("#errorMsg").html(result.message);
                        }
                    }
                })
            })
        });
    </script>
</head>

<body>
<div class="panel panel-default" id="userSet">
    <div class="panel-heading">
        <h3 class="panel-title">评论审核</h3>
    </div>
    <div>
        <input type="button" value="查询" class="btn btn-success" id="doSearch" style="margin: 5px 5px 5px 15px;"/>
        <input type="button" class="btn btn-primary" id="show-user-search" value="展开搜索"/>
        <input type="button" value="收起搜索" class="btn btn-primary" id="upp-user-search" style="display: none;"/>
    </div>

    <div class="panel-body">
        <div class="showusersearch" style="display: none;">
            <form class="form-horizontal" id="searchForm" action="${pageContext.request.contextPath}/comment/findAll">
                <div class="form-group">
                    <div class="form-group col-xs-6">
                        <input type="hidden" id="pageNo" name="pageNo">
                        <label for="nickname" class="col-xs-3 control-label">用户名：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="nickname" name="nickname" placeholder="请输入用户名"/>
                        </div>
                    </div>
                    <div class="form-group col-xs-6">
                        <label for="context" class="col-xs-3 control-label">评论内容：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="context" name="context" placeholder="请输入评论内容"/>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="form-group col-xs-6">
                        <label for="createStartDate" class="col-xs-3 control-label">开始日期：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="createStartDate" name="createStartDate" placeholder="请输入评论开始时间:2017-10-10"/>
                        </div>
                    </div>
                    <div class="form-group col-xs-6">
                        <label for="createEndDate" class="col-xs-3 control-label">结束日期：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="createEndDate" name="createEndDate" placeholder="请输入评论结束时间:2017-10-12"/>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="form-group col-xs-6">
                        <label for="status" class="col-xs-3 control-label">状态：</label>
                        <div class="col-xs-8">
                            <select class="form-control" id="status" name="status" >
                                <option value="-1" >全部</option>
                                <option value="2" >待审核</option>
                                <option value="1" >禁用</option>
                                <option value="0" >启用</option>
                            </select>
                        </div>
                    </div>
                </div>

            </form>
        </div>

        <div class="show-list">
            <table class="table table-bordered table-hover" style='text-align: center;'>
                <thead>
                <tr class="text-danger">
                    <th class="text-center">编号</th>
                    <th class="text-center">评论内容</th>
                    <th class="text-center">用户名</th>
                    <th class="text-center">评论时间</th>
                    <th class="text-center">赞</th>
                    <th class="text-center">状态</th>
                    <th class="text-center">操作</th>
                </tr>
                </thead>
                <tbody id="tb">
                <c:forEach items="${commentPage.list}" var="comment">
                    <tr>
                        <td>${comment.id}</td>
                        <td>${comment.context}</td>
                        <td>${comment.user.nickname}</td>
                        <td>${comment.createDate}</td>
                        <td>${comment.like}</td>
                        <c:if test="${comment.status == 2}">
                            <td>待审核</td>
                        </c:if>
                        <c:if test="${comment.status == 1}">
                            <td>禁用</td>
                        </c:if>
                        <c:if test="${comment.status == 0}">
                            <td>启用</td>
                        </c:if>
                        <td class="text-center">
                            <c:if test="${comment.status == 2}">
                                <input type="button" class="btn btn-success btn-sm0" data-id="${comment.id}" value="通过"/>
                                <input type="button" class="btn btn-danger btn-sm1" data-id="${comment.id}" value="禁用"/>
                            </c:if>
                            <c:if test="${comment.status == 1}">
                                <input type="button" class="btn btn-success btn-sm0" data-id="${comment.id}" value="启用"/>
                            </c:if>
                            <c:if test="${comment.status == 0}">
                                <input type="button" class="btn btn-danger btn-sm1" data-id="${comment.id}" value="禁用"/>
                            </c:if>

                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <ul id="userPageHelper"></ul>
        </div>

        <!-- 分页 -->
<%--                <div style="text-align: center;" >--%>
<%--                    <ul id="myPages" ></ul>--%>
<%--                </div>--%>

    </div>
</div>
</body>

</html>
